package com.alliky.core.net.interceptor

import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response


/**
 * @author wxianing
 * @date 2018/9/26
 * @desc QueryParameterInterceptor 设置公共参数
 */
class QueryParameterInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val originalRequest = chain.request()
        val request: Request

        val modifiedUrl = originalRequest.url().newBuilder()
            .addQueryParameter("platform", "android")
            .addQueryParameter("timestamp", System.currentTimeMillis().toString())
            .build()
        request = originalRequest.newBuilder().url(modifiedUrl).build()

        return chain.proceed(request)
    }
}